package gui;

import java.awt.Component;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.TableCellRenderer;

import utils.ImageLoader;

public class PlayerHandCellRenderer extends JLabel implements TableCellRenderer {

    public PlayerHandCellRenderer() {
        setOpaque(false);
        setFont(new Font("Arial", Font.BOLD, 49));
        this.setHorizontalAlignment(SwingConstants.CENTER);
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        int cellValue = ((Integer) value).intValue();
        ImageLoader loader = ImageLoader.getLoader();

        if (cellValue != -1) {
            setIcon(loader.getIcon(Properties.IMAGE_DIR + Properties.SUFFIX + cellValue + (row == 0 ? Properties.UP : Properties.DOWN)));
            setOpaque(false);
        } else {
            setIcon(loader.getIcon(Properties.IMAGE_DIR + "wood.jpg"));
        }
        return this;
    }
}
